﻿namespace Sidvall.CodeGenerator
{
	public class EntityMappingCollection : System.Collections.ObjectModel.KeyedCollection<string, EntityMapping>
	{
		#region Public Members

		public void Add(string name, string newName)
		{
			EntityMapping item;

			item = new EntityMapping()
			{
				Name = name,
				NewName = newName,
				Ignore = false
			};
			Add(item);
		}
		public void Ignore(string name)
		{
			EntityMapping item;

			item = new EntityMapping()
			{
				Name = name,
				Ignore = true
			};
			Add(item);
		}
		public EntityMapping GetItem(string name)
		{
			if (string.IsNullOrWhiteSpace(name))
				return null;
			name = name.ToUpperInvariant();
			if (Contains(name))
				return this[name];
			else
				return null;
		}
		protected override string GetKeyForItem(EntityMapping item)
		{
			if (item == null)
				throw new System.ArgumentNullException("item");
			return item.Name.ToUpperInvariant();
		}

		#endregion
		#region Constructors

		public EntityMappingCollection()
			: base(System.StringComparer.OrdinalIgnoreCase)
		{
		}

		#endregion
	}
}
